package com.example.demo.controller;

import com.example.demo.entity.Classroom;
import com.example.demo.service.ClassRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@CrossOrigin
public class ClassRoomController {

    @Autowired
    ClassRoomService classRoomService;

    @PostMapping("/classroom")
    public int save(@RequestBody Classroom classroom){
        return classRoomService.save(classroom);
    }

    @DeleteMapping("/classroom/{crId}")
    public int delete(@PathVariable("crId") int crId){
        return classRoomService.delete(crId);
    }

    @PutMapping("/classroom")
    public int update(@RequestBody Classroom classroom){
        return classRoomService.update(classroom);
    }

    @GetMapping("/classroom")
    public List<Classroom> select(){
        return classRoomService.select();
    }
}
